<template>

  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="600px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="90px" style="padding-left: 10%;">
      <el-form-item label="分类名称:" prop="categoryName">
        <el-input v-model="queryParams.categoryName"></el-input>
      </el-form-item>
      <el-form-item label="排序:" prop="sort">
        <el-input v-model="queryParams.sort"></el-input>
      </el-form-item>
      <el-form-item label="状态:" prop="status">
        <el-radio-group v-model="queryParams.status">
          <el-radio :label="1">正常</el-radio>
          <el-radio :label="0">隐藏</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
export default {
  name: "addForm",
  data() {
    return {
      open: false,
      title: "添加分类",
      form: {
        categoryId: "",
        categoryName: ""
      },
      rules: {
        categoryId: [
          { required: true, message: "Please select a category", trigger: "change" }
        ],
        categoryName: [
          { required: true, message: "Please enter a category name", trigger: "blur" }
        ]
      },
      queryParams: {
        categoryId: "",
        categoryName: ""
      },
      active: 1,
      baseInput: 200,
      data: []
    }
  },
  methods: {
    add() {
      this.open = true;
    },
    submitForm() {
      this.$refs.form.validate(valid => {
        if (valid) {
          // Perform form submission logic here
        } else {
          // Handle form validation errors
        }
      });
    },
    cancel() {
      this.open = false;
    },
    categoryChange(value) {
      this.form.categoryId = value;
    }
  }
}
</script>

<style lang="scss" scoped></style>